﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dbPoll_Application.ViewModels.ParticipantFieldViewModel>" %>

<div style="overflow:auto;max-height:640px">
<table class="questions">
    <thead>
        <tr>
        <th>Device ID</th>
        <th>First Name</th>
        <th>Last Name</th>
            <% int i = 0;
               foreach (var field in Model.poll.participantFields)
               {%>
                <th>
                    <%=field.name%>
                </th><%
                i++;
                if (i>3) { break; }
               } 
            %>
        <th>Entity</th>
        </tr>
    </thead>
    <tbody>
        <% 
            foreach (var participant in Model.fieldValues)
           {
               
        %>
        <tr>
            <%  
                int j = 0;
                foreach (var field in participant)
                {
                    
                    if (field.Key.Equals("Device ID") || field.Key.Equals("Username"))
                    {%> <td><%= Html.ActionLink(field.Value, "Details", "Participant", new { participantID = participant.ElementAt(0).Value, pollID = Model.poll.pollID }, null)%></td>
                    <%}
                    else if (field.Key!="Participant ID")
                    {%><td><%=field.Value%></td>
                <%}
                    j++;
                    if (j > 7) { break; }
                }%>
       <% if (Model.poll.participantFields.Count > 3) {%><td><%= participant.Last().Value %></td><%} %></tr>
        <% 
        } %>
    </tbody>
</table>
</div>